package com.alatus.djl.app;

import com.alatus.djl.service.HardnessAssessmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/api/hardness")
@Slf4j
public class HardnessAssessmentController {

    @Autowired
    private HardnessAssessmentService hardnessService;

    @PostMapping("/assess")
    public String assessHardness(@RequestParam String datasetPath,
                                 @RequestParam String modelPath) {
        try {
            hardnessService.trainAndAssessHardness(datasetPath, modelPath);
            return "Hardness assessment completed successfully";
        } catch (IOException e) {
            log.error("Hardness assessment failed", e);
            return "Hardness assessment failed: " + e.getMessage();
        }
    }

    @GetMapping("/status")
    public String getStatus() {
        return "Hardness assessment service is running";
    }
}